package org.chl.chapter05.logic;

import java.util.List;

import org.chl.chapter05.dao1.UserDao;
import org.chl.chapter05.dao2.UserDao2;
import org.chl.chapter05.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserLogic {
	
	@Autowired
	UserDao userDao;
	
	@Autowired
	UserDao2 userDao2;

	public User save(User user) {
		return userDao.save(user);
	}

	public void deleteUserById(Integer id) {
		userDao.deleteById(id);;
	}

	public User getUserById(Integer id) {
		return userDao2.getOne(id);
	}

	public List<User> getAllUsers() {
		return userDao2.findAll();
	}

}
